target: entity
	@make dll

include $(CPPWEB_INSTALL_HOME)/makeconf

OBJ_PATH 	= bin/obj
DLL_OUTPUT  = bin/webapp.so

ALLSRC = $(wildcard *.cpp) $(wildcard app/*.cpp) $(wildcard cgi/*.cpp) $(wildcard dao/*.cpp)
ALLOBJ = $(patsubst %.cpp, $(OBJ_PATH)/%.o, $(filter %.cpp, $(ALLSRC)))

INCPATH	 = -I$(LIBRARY_PATH) -I. -I./inc -I$(CPPWEB_INSTALL_HOME)/webapp/cpp/lib
LIBLINK	 = -L$(LIB_OUTPUT_PATH) -lwebx -lhttp -lweb.dbentity -ldbx.base -lzlib -lstdx -lclib -ljson

$(OBJ_PATH)/%.o:%.cpp
	$(CPP) -DXG_DLL $(INCPATH) $(INC_OPENSSL) -c -o $@ $<

dll: init check $(ALLOBJ)
	$(DELETEFILE) $(DLL_OUTPUT)
	$(CPP_DLL) -o $(DLL_OUTPUT) $(ALLOBJ) $(LIBLINK) $(LIB_OPENSSL) $(PLATFORMLINK)

init:
	@$(MKDIR) -p $(OBJ_PATH)
	@$(MKDIR) -p $(OBJ_PATH)/app
	@$(MKDIR) -p $(OBJ_PATH)/cgi
	@$(MKDIR) -p $(OBJ_PATH)/dao

clean:
	@$(DELETEFILE) -rf $(OBJ_PATH)/*

check:
	@$(BIN_OUTPUT_PATH)/checkmake$(BIN_EXTNAME)

entity:
	@$(BIN_OUTPUT_PATH)/cgientity$(BIN_EXTNAME) -c -o cgi